package com.woniu.controller;


import com.woniu.service.ChatService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;


/**
 * @Author 朱杰
 * @Date 2025/6/8 17:53
 * @Description
 */
@RestController
@RequestMapping("/ai/")
@RequiredArgsConstructor
public class ChatController {

    private final ChatService chatService;

    @GetMapping(value = "chat", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> chat(@RequestParam("userId") String userId, @RequestParam("userInput") String userInput) {
        return chatService.processQuery(userId, userInput);
    }

    @GetMapping("clearContext")
    public void clearContext(String userId) {
        System.out.println("清空上下文");
        chatService.clearContext(userId);
    }
}
